import asyncio
from apscheduler.schedulers.asyncio import AsyncIOScheduler


async def my_task():
    print("Running task...")
    # 在这里添加你的异步任务代码

scheduler = AsyncIOScheduler()
scheduler.add_job(my_task, 'interval', seconds=5)
scheduler.start()

# 防止脚本退出
asyncio.get_event_loop().run_forever()